//
//  PicPickerViewCell.swift
//  WBDemo
//
//  Created by Jin on 2018/5/15.
//  Copyright © 2018年 com.baidu.123. All rights reserved.
//

import UIKit

class PicPickerViewCell: UICollectionViewCell {
    
    @IBOutlet weak var addImageBtn:UIButton!
    @IBOutlet weak var deleteImageBtn:UIButton!
    
    var image:UIImage? {
        didSet{
            if image != nil {
                addImageBtn.setBackgroundImage(image, for: .normal)
                addImageBtn.isUserInteractionEnabled = false
                deleteImageBtn.isHidden = false
            }else {
                addImageBtn.setBackgroundImage(UIImage(named: "tabbar_compose_icon_add"), for: .normal)
                addImageBtn.isUserInteractionEnabled = true
                deleteImageBtn.isHidden = true
            }
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
    }
    
    @IBAction func addPhotoBtnClick(_ sender: UIButton) {
        NotificationCenter.default.post(Notification(name: Notification.Name(rawValue: JLPicPickerAddPhotoNote)))
    }
    
    @IBAction func deletePhotoBtnClick(_ sender: UIButton) {
        NotificationCenter.default.post(name: Notification.Name(rawValue: JLPicPickerDeletePhotoNote), object: addImageBtn.currentBackgroundImage)
    }
    

}
